package com.example.noelwhereismystuffs.models;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class UserDbHelper extends SQLiteOpenHelper {
	
	  public static final String TABLE_NAME = "user";
	  public static final String COLUMN_ID = "_id";
	  public static final String COLUMN_NAME = "username";
	  public static final String COLUMN_EMAIL = "email";
	  public static final String COLUMN_PASSWORD = "password";
	 // public static final String COLUMN_UID = "uid";

	  private static final String DATABASE_NAME = "lostandfound.db";
	  private static final int DATABASE_VERSION = 1;

	public UserDbHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.d(UserDbHelper.class.getName(), "Ready to create database table user");
		 db.execSQL("CREATE TABLE "
			      + TABLE_NAME + "(" 
				  + COLUMN_ID  + " integer primary key autoincrement, " 
			      + COLUMN_NAME + " text not null, " 
				  + COLUMN_EMAIL + " text unique not null, " 
			      + COLUMN_PASSWORD + " text not null) ;"
			 );
		 Log.d(UserDbHelper.class.getName(),"Created Database table user");
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(UserDbHelper.class.getName(),
		        "Upgrading database from version " + oldVersion + " to "
		            + newVersion + ", which will destroy all old data");
		    db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		    onCreate(db);
	}

}
